package com.xingfly.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xingfly.dao.UserDao;
import com.xingfly.model.dto.User;
import com.xingfly.service.UserService;
@Service("userService")
public class UserServiceImpl implements UserService{
	@Resource
	private UserDao userDao;
	/**
	 * 查询全部人员
	 */
	@Override
	public List<User>SelByAll(){
		List<User> selByAlls=null;
		try {
			 selByAlls = userDao.SelByAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return selByAlls;
	}
	/**
	 * 根据类型查询
	 */
	@Override
	public List<User> SelByType(String type) {
		List<User> selByType =null;
		try {
			selByType = userDao.SelByType(type);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return selByType;
	}
	/**
	 * 根据偏好查询
	 */
	@Override
	public List<User> SelByPrefer(String prefer) {
		    List<User>selByprefer=null;
			try {
				selByprefer = userDao.SelByPrefer(prefer);
			} catch (Exception e) {
				e.printStackTrace();
			}
		return selByprefer;
	}
	/**
	 * 页面加载的时候 加载状态为0的乘客
	 */
	@Override
	public List<User> SelBycond(int cond){
		List<User> selBycond=null;
		 try {
			selBycond = userDao.SelBycond(cond);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return selBycond;
	}
	/**
	 * 更改选定的用户状态更改为 1
	 */
	@Override
	public int update(int cond, int uid){
				int update=0;
		try {
			 update = userDao.update(cond, uid);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return update;
	}
	/**
	 * 清空用户表 updUserAll
	 */
	@Override
	public int updUserAll() {
		int delUserAll=0;
		try {
			delUserAll = userDao.updUserAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return delUserAll;
	}
	/**
	 * 根据id查询全部用户 
	 */
	@Override
	public List<User> SelByid(int uid) {
		List<User> selByid=null;
		try {
			selByid = userDao.SelByid(uid);
		} catch (Exception e) {
			e.printStackTrace();
		}  
		return selByid;
	}
}
